Fk:loadTranslationTable{
  ["dajubei__ligang"] = "励纲",
  [":dajubei__ligang"] = "一名其他角色的出牌阶段开始时，你可以交给其所有手牌。若如此做，此回合内其使用通常锦囊牌时，你可以选择一项：1.摸一张牌；2.从其手牌中获得你交给其牌数张牌。",

  ["dajubei__ligang-obtain"] = "获得牌",
  ["#dajubei__ligang-choose"] = "励纲：摸牌，或获得 %src 的%arg张手牌",
  ["#dajubei__ligang-obtain"] = "励纲：选择 %src 的%arg张手牌获得"
}

local ligang = fk.CreateSkill{
  name = "dajubei__ligang",
}

local function addLigangMark(target, from, num)
  local mark = target:getTableMark("@@dajubei__ligang-turn")
  table.insertIfNeed(mark, {from.id, num})
  target.room:setPlayerMark(target, "@@dajubei__ligang-turn", mark)
end

ligang:addEffect(fk.EventPhaseStart, {
  anim_type = "support",
  can_trigger = function (self, event, target, player, data)
    if player:hasSkill("dajubei__ligang") then
      return data.phase == Player.Play and not player:isKongcheng()
    end
  end,
  on_use = function (self, event, target, player, data)
    if player:isKongcheng() or target.dead then return end
    local room = player.room
    local cards = player:getCardIds("h")
    addLigangMark(target, player, #cards)
    room:moveCardTo(cards, Card.PlayerHand, target, fk.ReasonGive, ligang.name, nil, false, player)
  end
})

ligang:addEffect(fk.CardUsing, {
  is_delay_effect = true,
  anim_type = "drawcard",
  can_trigger = function (self, event, target, player, data)
    if table.find(target:getTableMark("@@dajubei__ligang-turn"), function (t) return t[1] == player.id end) then
      return true
    end
  end,
  on_trigger = function (self, event, target, player, data)
    local room = player.room
    local num = table.find(target:getTableMark("@@dajubei__ligang-turn"), function (t) return t[1] == player.id end)[2] ---@type integer
    local all_choices = {"draw1", "dajubei__ligang-obtain"}
    local choices = table.simpleClone(all_choices)
    if num > target:getHandcardNum() then
      choices = table.remove(choices, 2)
    end
    local ret = room:askToChoice(player, {
      all_choices = all_choices,
      choices = choices,
      cancelable = false,
      skill_name = ligang.name,
      prompt = "dajubei__ligang-choose:" .. target.id .. "::" .. num,
    })
    if ret == all_choices[2] then
      room:askToChooseCards(player, {
        target = target,
        min = num,
        max = num,
        flag = "h",
        skill_name = ligang.name,
        prompt = "#dajubei__ligang-obtain:" .. target.id .. "::" .. num,
      })
    else
      player:drawCards(1, ligang.name)
    end
  end
})

return ligang